﻿
using System.Data;
using System.Data.OleDb;
using Resources;

public class ConnectionBase
{
    protected OleDbConnection myConnection;
    protected DataSet dataSet = new DataSet();
    public ConnectionBase()
    {
        openConnection();
    }
    public void openConnection()
    {
        string myConnectionString;
        myConnectionString = Resource.ConnectionString;

        myConnection = new OleDbConnection(myConnectionString);
        myConnection.Open();
    }
    public DataSet consultSQL(string sql)
    {
        OleDbDataAdapter adapter = new OleDbDataAdapter(sql, this.myConnection);
        dataSet.Clear();
        adapter.Fill(dataSet);
        return dataSet;
    }
    public void consultSQLNew(string sql)
    {
        OleDbDataAdapter adapter = new OleDbDataAdapter(sql, this.myConnection);
        //dataSet.Clear();
       
        adapter.Fill(dataSet);
    }
    public int executeSQL(string sql)
    {
        OleDbCommand myCommand = new OleDbCommand(sql);
        myCommand.Connection = this.myConnection;
        return myCommand.ExecuteNonQuery();
       
    }
}
